package com.yonyou.cyxdms.basedata.service.controller.vehicleproduct;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyx.framework.controller.base.BaseController;
import com.yonyou.cyxdms.basedata.service.dto.vehicleprice.ProductPriceDTO;
import com.yonyou.cyxdms.basedata.service.service.product.VsProductPriceService;
import com.yonyou.cyxdms.basedata.service.vo.productprice.ProductPriceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 主数据价格维护
 *
 * @author renwd
 * @since 2019-07-22
 */

@Api(value = "VsProductPriceController", tags = "车辆颜色")
@RestController
@RequestMapping("/vehicleMasterPrice")
public class VsProductPriceController extends BaseController {

    @Autowired
    public VsProductPriceService vsProductPriceService;

    /**
     * 主数据价格维护
     *
     * @param pageNum
     * @param pageSize
     * @param queryParam
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yonyou.cyxdms.basedata.service.vo.productprice.ProductPriceVO>
     * @author renwd
     * @since 2019/7/23
     */
    @ApiOperation(value = "主数据价格维护", notes = "主数据价格维护")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping
    public IPage<ProductPriceVO> listVehicleMasterPrice(@RequestParam("pageNum") Long pageNum, @RequestParam("limit") Long pageSize,
                                                        @RequestParam Map<String, Object> queryParam) {
        Page<ProductPriceVO> page = new Page<>(pageNum, pageSize);
        return vsProductPriceService.listVehicleMasterPrice(page, queryParam);
    }

    /**
     * 主数据价格新增
     *
     * @param productPriceDTO
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/23
     */
    @ApiOperation(value = "主数据价格新增", notes = "主数据价格新增")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping
    public Integer addProductPrice(@RequestBody ProductPriceDTO productPriceDTO) {
        return vsProductPriceService.addProductPrice(productPriceDTO);
    }

    /**
     * 主数据价格修改
     *
     * @param id
     * @param productPriceDTO
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/23
     */
    @ApiOperation(value = "主数据价格修改", notes = "主数据价格修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PutMapping("/{id}")
    public Integer modifyProductPrice(@PathVariable("id") Long id, @RequestBody ProductPriceDTO productPriceDTO) {
        return vsProductPriceService.modifyProductPrice(id, productPriceDTO);
    }

    /**
     * 主数据价格批量更新
     *
     * @param productPriceDTO
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/23
     */
    @ApiOperation(value = "主数据价格批量更新", notes = "主数据价格批量更新")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PutMapping("/update")
    public Integer batchUpdateProductPrice(@RequestBody ProductPriceDTO productPriceDTO) {
        return vsProductPriceService.updateProductPrice(productPriceDTO);
    }

}